#coding=UTF-8
import requests
import json

# 引入自定义的keystone模块
import keystone
keystone_s=keystone.getToken()


volumes_url="http://192.168.100.10:8774/v2.1/os-volumes"

headers={
    "X-Auth-Token":keystone_s['token'],
    "Content-Type": "application/json"
}
body={
    "volume": {
        "display_name": "Volume Name",
        "display_description": "Volume Description",
        "size": 10
    }
}

req=requests.post(volumes_url,headers=headers,data=json.dumps(body))
if req.status_code==200:
    print ("创建成功")
print (json.dumps(req.json(),sort_keys=True,indent=4))